<?php
/**
 * Created by PhpStorm.
 * User: bobo
 * Date: 18-4-4
 * Time: 上午11:21
 */

namespace WsdServer\Lib\Facade;


class DB
{
    /**
     * Handle dynamic, static calls to the object.
     *
     * @param  string  $method
     * @param  array   $args
     * @return mixed
     *
     * @throws \RuntimeException
     */
    public static function __callStatic($method, $args)
    {
        //$instance = static::getFacadeRoot();

        /*
        $connections = get_instance()->getLaravelDatabase()->getDatabaseManager()->getConnections();
        // Connect
        $capsule::connection();
        $instance = $connections['default'];
        */

        $instance = get_instance()->getLaravelDBConnect();

        if (!$instance) {
            $instance = get_instance()->getLaravelDatabase()->getConnection('default');
            if (!$instance) {
                throw new RuntimeException('==== A facade root has not been set.');
            }
        }

        return $instance->$method(...$args);
    }

}